﻿using System;
using Rainbow.ObjectFlow.Interfaces;

namespace Rainbow.ObjectFlow.Engine
{
    internal abstract class WorkflowBuilder<T> where T : class
    {
       internal delegate void OperationAddedEventHandler(OperationDuplex<T> operation );

        // TODO decouple this
        public ParallelInvoker<T> ParallelOperations;

        public event OperationAddedEventHandler OperationAdded;

        protected void RaiseOperationAddedEvent(OperationDuplex<T> operation )
        {
            if (null != OperationAdded)
                OperationAdded(operation);
        }

        public abstract void AddOperation(IOperation<T> operation);

        public abstract void AddOperation(IOperation<T> operation, ICheckConstraint constraint);

        public abstract void AddOperation(Func<T, T> function);

        public abstract void AddOperation(Func<T, T> function, ICheckConstraint constraint);

        public abstract void AddOperation(IExecuteWorkflow<T> operation);

        public abstract void AddOperation(IExecuteWorkflow<T> workflow, ICheckConstraint constraint);

        public abstract void AddOperation<TOperation>();

        public abstract void AddOperation<TOperation>(ICheckConstraint constraint);
    }
}